package example

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
	"github.com/tidwall/pretty"
)
func PrettyJson(a fyne.App) {
	w:=a.NewWindow("pretty json : https://hub.fastgit.org/tidwall/pretty")
	w.Resize(fyne.NewSize(600, 600))
	left := widget.NewMultiLineEntry()
	left.SetText(`
		{"name":  {"first":"Tom","last":"Anderson"},  "age":37,
"children": ["Sara","Alex","Jack"],
"fav.movie": "Deer Hunter", "friends": [
    {"first": "Janet", "last": "Murphy", "age": 44}
  ]}
		`)
	right := widget.NewMultiLineEntry()
	top := container.NewHBox(
		widget.NewButton("pretty", func() {
			right.SetText(string(pretty.Pretty([]byte(left.Text))))
		}),
		widget.NewButton("ugly", func() {
			right.SetText(string(pretty.Ugly([]byte(left.Text))))
		}),
	)
	c1 := container.NewBorder(top, nil, nil, nil,
		container.NewGridWithColumns(2, left, right))
	w.SetContent(c1)
	w.CenterOnScreen()
	w.Show()
}
